home *** CD-ROM | disk | FTP | other *** search
-
- #include "Interface-Effect.h"
-
- //———————————————————————————————————————————————
- // Perform the effect
-
- #define kDefaultWidth 80
- #define kDefaultHeight 60
- #define kDefaultLeft 0
- #define kDefaultTop 0
-
- #define kMinTotalMem 5000
- #define kMinContigMem 4000
-
- #define kDialogID 1000
- #define kOKItem 1
- #define kLeftItem 2
- #define kTopItem 3
- #define kWidthItem 4
- #define kHeightItem 5
-
- OSErr DoTheDialog( EffectHandle theData );
- void SetDialogNumber( DialogPtr theDialog, short theItem, long theValue );
- long GetDialogNumber( DialogPtr theDialog, short theItem );
-
-
- pascal short main(short selector, EffectHandle theData)
- {
- short result = 0;
- Rect aRect, bRect, dRect;
- Rect theBlueRect;
- CGrafPtr oldPort;
- GDHandle oldGDevice;
- RGBColor blueColor, oldColor;
-
- switch (selector)
- {
- case esExecute:
- GetGWorld( &oldPort, &oldGDevice );
- aRect = ((GrafPtr)(*theData)->source1)->portRect;
- bRect = ((GrafPtr)(*theData)->source2)->portRect;
- dRect = ((GrafPtr)(*theData)->destination)->portRect;
-
- // copy all of source 1
- CopyBits((BitMap*)&(*theData)->source1->portPixMap,
- (BitMap*)&(*theData)->destination->portPixMap,
- &aRect,&dRect,srcCopy,nil);
-
- // get the rectangle
- if ( (**theData).specsHandle )
- {
- theBlueRect = **(Rect**)(**theData).specsHandle;
- }
- else
- {
- SetRect( &theBlueRect, kDefaultLeft, kDefaultTop,
- kDefaultLeft + kDefaultWidth, kDefaultTop + kDefaultHeight );
- }
- SetGWorld( (*theData)->destination, NULL );
- blueColor.red = blueColor.green = 5000;
- blueColor.blue = 45000L;
- GetForeColor( &oldColor );
- RGBForeColor( &blueColor );
- PaintOval( &theBlueRect );
- RGBForeColor( &oldColor );
- SetGWorld( oldPort, oldGDevice ); // restore port
- break;
- case esSetup:
- result = DoTheDialog( theData );
- break;
- }
- return(result);
- }
-
-
- OSErr DoTheDialog( EffectHandle theData )
- {
- Handle h = NULL;
- short itemHit;
- DialogPtr theDialog;
- long contigMem, totalMem;
- Rect r;
-
- InitCursor(); // Premiere leaves it as something dumb
-
- PurgeSpace( &totalMem, &contigMem );
- if ( (totalMem < kMinTotalMem) || (contigMem < kMinContigMem) )
- return( memFullErr );
-
- if ( (**theData).specsHandle )
- r = **(Rect**)(**theData).specsHandle;
- else
- {
- h = NewHandle( sizeof(Rect) );
- if ( !h ) return( memFullErr );
- SetRect( &r, kDefaultLeft, kDefaultTop,
- kDefaultLeft+kDefaultWidth, kDefaultTop+kDefaultHeight );
- }
-
- theDialog = GetNewDialog( kDialogID, NULL, (WindowPtr)-1 );
- if ( !theDialog ) return( resNotFound );
-
- SetDialogNumber( theDialog, kLeftItem, r.left );
- SetDialogNumber( theDialog, kTopItem, r.top );
- SetDialogNumber( theDialog, kWidthItem, r.right - r.left );
- SetDialogNumber( theDialog, kHeightItem, r.bottom - r.top );
- SelIText( theDialog, kLeftItem, 0, 999 );
-
- do
- {
- ModalDialog( NULL, &itemHit );
- } while ( itemHit != kOKItem );
-
- r.left = GetDialogNumber( theDialog, kLeftItem );
- r.top = GetDialogNumber( theDialog, kTopItem );
- r.right = r.left + GetDialogNumber( theDialog, kWidthItem );
- r.bottom = r.top + GetDialogNumber( theDialog, kHeightItem );
-
- if ( h )
- {
- (**(Rect**)h) = r;
- (**theData).specsHandle = h;
- }
- else
- **(Rect**)(**theData).specsHandle = r;
-
- DisposeDialog( theDialog );
- return( noErr );
- }
-
- void SetDialogNumber( DialogPtr theDialog, short theItem, long theValue )
- {
- short itemKind;
- Handle itemHandle;
- Rect itemR;
- Str255 aString;
-
- GetDItem( theDialog, theItem, &itemKind, &itemHandle, &itemR );
- NumToString( theValue, aString );
- SetIText( itemHandle, aString );
- }
-
- long GetDialogNumber( DialogPtr theDialog, short theItem )
- {
- short itemKind;
- Handle itemHandle;
- Rect itemR;
- long result = 0;
- Str255 aString;
-
- GetDItem( theDialog, theItem, &itemKind, &itemHandle, &itemR );
- GetIText( itemHandle, aString );
- StringToNum( aString, &result );
-
- return( result );
- }
-
-